Repository navigation
Add experimental support for Event Groups (implicit and scope propagation) - #3198
Conversation
Commands issued inside EventGroup.run, and from signal and update handlers, carry the active groups. Promise continuations do not capture that scope.
c018f14 to
4fb7280
Compare
| threadContext.initialYield(); | ||
| cancellationScope.run(); | ||
| eventGroupScope.run( | ||
| () -> { |
There was a problem hiding this comment.
Can we add an overload for this case to just write eventGroupScope.run(cancellationScope::run)
| TimerOptions.newBuilder() | ||
| .addEventGroups(options.getEventGroups().toArray(new EventGroup[0])) | ||
| .build()) | ||
| eventGroupScope |
There was a problem hiding this comment.
This does change the overload that gets called in the interceptors, was this intentional? I think we changed this call when you first added event groups so maybe a NOOP
There was a problem hiding this comment.
Yes, that's intentional. This restores interceptor that was original called before #3197, given that we can now pass EGs through scope propagation instead of direct attachment. Not breaking since we haven't published a release between PR 3197 and now.
I anticipate we may want to come back to the two args form at some point to propagate other options that will not support scope-propagation, like user metadata, but there's no reason to do this today.
| } | ||
|
|
||
| @Override | ||
| public <R> R run(Functions.Func<R> func) { |
There was a problem hiding this comment.
nit: we could add a check that we are in a workflow here
What was changed
Add experimental support for implicit Event Groups and scope-based propagation. This follows #3197, which added direct assignment.
EventGroup.runattaches the group to commands issued inside the callback. Nested scopes compose, and the earliest label for an id wins.addEventGroupsand the active scope are additive.Async.functionorAsync.procedurekeeps the scope that was active when it was started.Promise continuations (
thenApply,handle,thenCompose,exceptionally) do not capture the scope. They run on the thread that completes the promise, which is howCancellationScopeandWorkflowThreadLocalalready behave. Adopting a different behavior only for Event Groups would be inconsistent with other existing APIs. Extending context propagation on all APIs to also propagate to Promise continuations seems a desirable thing on the long term, but it is outside the scope of this PR, and would be a breaking behavior changes for existing workflows; we instead propose to delay this until the Java v2 SDK.